import 'package:base_flutter/base_flutter.dart';
import 'package:ls_work/login/page/user_manager.dart';
import 'package:ls_work/print/week_print_data.dart';
// import 'package:sunmi_printer_plus/column_maker.dart';
// import 'package:sunmi_printer_plus/enums.dart';
// import 'package:sunmi_printer_plus/sunmi_printer_plus.dart';
// import 'package:sunmi_printer_plus/sunmi_style.dart';

import '../net/response/food/week_menu_list_data.dart';

class SunmiPrinterUtils {
  static bool printBinded = false;

  static Future<bool> initSunmiPrinter() async {
    // printBinded = await SunmiPrinter.bindingPrinter()??false;
    print(printBinded);
    return printBinded;
  }

  static Future<void> printWeekOrder(String oldName,String oldRoom,List<WeekPrintData> data) async {
    if (!printBinded) {
      return;
    }
    for (var item in data) {
      await printSingleWeekOrder(oldName,oldRoom,item);
    }
  }

  static Future<void> printSingleWeekOrder(String oldName,String oldRoom,WeekPrintData data) async {
    if (!printBinded) {
      return;
    }

    // await SunmiPrinter.initPrinter();
    // var paperSize = 58;
    // var size = paperSize;
    // print("打印纸尺寸${size}");
    // await SunmiPrinter.startTransactionPrint(true);
    // await SunmiPrinter.printText("消费单\n",
    //     style: SunmiStyle(
    //         fontSize: SunmiFontSize.LG, align: SunmiPrintAlign.CENTER));
    // await SunmiPrinter.setCustomFontSize(23);
    // await SunmiPrinter.printText("老人姓名：${oldName}");
    // await SunmiPrinter.printText("点餐员：${UserManager.userName}");
    // await SunmiPrinter.printText("房间号：${oldRoom}");
    // await SunmiPrinter.printText("就餐日期：${data.date}");
    // // await SunmiPrinter.printText("餐别：${data.time}",style: SunmiStyle(
    // //     fontSize: SunmiFontSize.LG,));
    // await SunmiPrinter.printRow(cols: [
    //   ColumnMaker(text: '餐别',width: size~/10,align: SunmiPrintAlign.LEFT),
    //   ColumnMaker(text: '菜名',width: size~/6,align: SunmiPrintAlign.LEFT),
    //   ColumnMaker(text: '数量',width: size~/7,align: SunmiPrintAlign.LEFT),
    //   ColumnMaker(text: '金额',width: size~/7,align: SunmiPrintAlign.LEFT),
    // ]);
    // var count = 0;
    // var price = 0.0;
    // for(var type in (data.categaryList??<CategaryList>[])){
    //   for(var good in (type.goodsList??<GoodsList>[])){
    //     count+=1;
    //     price+=(good.price??0);
    //     await SunmiPrinter.printRow(cols: [
    //       ColumnMaker(text: data.time??"",width: size~/10,align: SunmiPrintAlign.LEFT),
    //       ColumnMaker(text: '${good.goodsName}',width: size~/6,align: SunmiPrintAlign.LEFT),
    //       ColumnMaker(text: 'x1',width: size~/7,align: SunmiPrintAlign.LEFT),
    //       ColumnMaker(text: '¥${good.price}',width: size~/7,align: SunmiPrintAlign.LEFT),
    //     ]);
    //   }
    // }


    // await SunmiPrinter.printRow(cols: [
    //   ColumnMaker(text: '合计数量：${count}',width: size~/3.5,align: SunmiPrintAlign.LEFT),
    //   ColumnMaker(text: '合计金额：${price}',width: size~/3.5,align: SunmiPrintAlign.LEFT),
    //
    // ]);
    // await SunmiPrinter.lineWrap(1);
    // await SunmiPrinter.line();
    // await SunmiPrinter.lineWrap(2);
    // await SunmiPrinter.cut();
    // await SunmiPrinter.exitTransactionPrint(true);
  }
}
